package christ.mmd.bl;

import java.util.Date;

import android.os.Parcel;
import android.os.Parcelable;

public class Fast extends DataItem implements Parcelable {
	public enum Type {
		None, Common, GreatLent, NativityFast, StPeterFast, DormitionFast, ChristmasEve, EpiphanyEve, BeheadingJohnBaptist, ExaltationCross;
		public static Type valueOfEx(String name) {
			Type result = None;
			if (name != null && name.trim().length() > 0) {
				result = Type.valueOf(name.trim());
			}
			return result;
		}
	}

	Type mType;
	Date mDateBegin;
	Date mDateEnd;
	String mDescription;

	public Fast(long id, String type, Date dateBegin, Date dateEnd,
			String description) {
		super(id);
		mType = Type.valueOfEx(type);
		mDateBegin = dateBegin;
		mDateEnd = dateEnd;
		mDescription = description;
	}

	public Fast(Parcel in) {
		this(in.readLong(), in.readString(), new Date(in.readLong()), new Date(
				in.readLong()), in.readString());
	}

	public Date getDateBegin() {
		return mDateBegin;
	}

	public Date getDateEnd() {
		return mDateEnd;
	}

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(mType.name());
		dest.writeLong(mDateBegin.getTime());
		dest.writeLong(mDateEnd.getTime());
		dest.writeString(mDescription);
	}

	public static final Parcelable.Creator<Fast> CREATOR = new Parcelable.Creator<Fast>() {
		public Fast createFromParcel(Parcel in) {
			return new Fast(in);
		}

		public Fast[] newArray(int size) {
			return new Fast[size];
		}
	};
}
